import fetch from '@/config/fetch';


//**********************************调查问卷*************************************//
/**
 * 根据ID查询调查问卷
 * @param {*调查问卷id} id 
 */
export function getQuestionById(questionnaireId, eid) {
    return fetch.get('/community/getQuestionById', {
        params: {
            questionnaireId, eid
        }
    })
}

/**
 * 保存用户调查问卷反馈
 * @param {企业id} eid 
 * @param {调查问卷id} questionnaireId 
 * @param {用户征集反馈} datas 
 */
export function saveQuestionnaireReceipt(eid, questionnaireId, finalDatas, activityId) {
    return fetch.post('/community/saveQuestionnaireReceipt', {
        eid,
        questionnaireId,
        finalDatas,
        activityId
    })
}

/**
 * 根据用户id和调查问卷id查询反馈
 * @param {*} eid 
 * @param {*} questionnaireId 
 */
export function getQuestionReceiptByUserIdAndQId(eid, questionnaireId, activityId) {
    return fetch.get('/community/getQuestionReceiptByUserIdAndQId', {
        params: {
            eid,
            questionnaireId,
            activityId
        }
    })
}


//**********************************投票*************************************//
/**
 * 根据投票id查询单个投票
 * @param {*投票id} voteId 
 */
export function getVoteById(voteId) {
    return fetch.get('/community/getVoteById', {
        params: {
            voteId,
        }
    })
}

/**
 * 根据投票ID和DatasId查询单个投票总数
 * @param {*投票id} voteId 
 * @param {*} datasId 
 */
export function getOneVoteByDatasIdAndVoteId(voteId, datasId) {
    return fetch.get('/community/getOneVoteByDatasIdAndVoteId', {
        params: {
            voteId,
            datasId,
        }
    })
}

/**
 * 根据投票id统计所有的投票数
 * @param {*投票id} voteId 
 */
export function findDatasAllByVoteId(voteId) {
    return fetch.get('/community/findDatasAllByVoteId', {
        params: {
            voteId,
        }
    })
}

/**
 * 保存投票反馈
 * @param {*} eid 
 * @param {*投票id} voteId 
 * @param {*投票结果} datas 
 */
export function saveVoteReceipt(eid, voteId, datas, datasId, activityId) {
    return fetch.post('/community/saveVoteReceipt', {
        eid,
        voteId,
        datas,
        datasId,
        activityId
    })
}

/**
 * 根据用户id、投票id、datasid查询单个投票回执
 * @param {企业id} eid 
 * @param {*投票id} voteId 
 */
export function getReceiptByParams(eid, voteId, activityId) {
    return fetch.get('/community/getReceiptByParams', {
        params: {
            eid,
            voteId,
            activityId
        }
    })
}


//**********************************征集*************************************//

/**
 * 根据征集id查询
 * @param {征集id} gainId 
 * @param {企业id} eid 
 */
export function getGainByGainId(gainId,eid) {
    return fetch.get('/community/getGainByGainId', {
        params: {
            gainId,
            eid
        }
    })
}

/**
 * 根据条件分页查询征集列表
 * @param {当前页数} pageNumber 
 * @param {每页显示几条数据} pageSize 
 * @param {企业id} eid 
 * @param {微信传来的条件} params 
 */
export function findGianPageListByParams(pageNumber, pageSize, eid, params) {
    return fetch.get('/community/findGianPageListByParams', {
        params: {
            pageNumber,
            pageSize,
            eid,
            params
        }
    })
}

/**
 * 保存用户征集反馈
 * @param {用户openId} openId 
 * @param {征集id} gainId 
 * @param {用户征集反馈} datas 
 * @param {活动id} activity_id 
 * @param {微信id} wxid 
 * @param {企业id} eid 
 * @param {分享者id} shareUserId 
 */
export function saveGainFeedback(gainId, datas, activity_id, eid,shareUserId) {
    return fetch.post('/community/saveGainFeedback', {
        gainId,
        datas,
        activity_id,
        eid,
        shareUserId
    })
}

/**
 * 根据条件分页查询征集回执列表
 * @param {当前页数} pageNumber 
 * @param {每页显示几条数据} pageSize 
 * @param {企业id} eid 
 * @param {微信传来的条件} params 
 */
export function findGainReceiptPageListByParams(pageNumber, pageSize, eid, params) {
    return fetch.get('/community/findGainReceiptPageListByParams', {
        params: {
            pageNumber,
            pageSize,
            eid,
            params
        }
    })
}

/**
 * 根据征集回执id查询单篇征集回执
 * @param {征集回执id} rid 
 */
export function getGainFeedbackById(rid) {
    return fetch.get('/community/getGainFeedbackById', {
        params: {
            rid
        }
    })
}

